package command_jss.reversible;
import java.util.*;
/*
 *  Command의 list를 관리하고 실행, 실행취소 등을 호출하는 역할을 하는 Command Stack
 * */
public class CommandStact{
	private int current = -1;
	private List<ReversibleCommand> commands = new ArrayList<ReversibleCommand>();
	
	public void excute(ReversibleCommand c){
		int size= commands.size()-1;
		for(int i=size;i>current;i--){
			commands.remove(i);
		}
		commands.add(c);
		redo();
	}

	public void redo() {
		// TODO Auto-generated method stub
		commands.get(++current).redo();
	}
	public void undo(){
		commands.get(current--).undo();
	}
	

}
